from ConectaMysql import *


class ControleAcesso(ConectaMysql):
    def __init__(self, hostServer = "127.0.0.1", userServer = "root", passwdServer = "", db = "automanage"):        
        ConectaMysql.__init__(self, hostServer, userServer, passwdServer, db)       


    def verificarUsuario(self, login, senha):
        result = self.executaQuery(
        "SELECT * FROM tb_usuario INNER JOIN tb_usuariosetor ON " +
        "tb_usuario.USUid = tb_usuariosetor.US_USUid WHERE " +
        "USUlogin = ('" + str(login) + "') and " +
        "USUsenha = ('" + str(senha) + "')")

        self.__quant = 0
        
        for linha in result:            
            self.__setor = linha["US_SETid"]
            self.__usuId = linha["USUid"]
            self.__usuNome = linha["USUnome"]
            self.__quant+=1
                    

    def quantLinhas(self):
        return self.__quant

    def getSetor(self):
        return self.__setor

    def getUsuId(self):
        return self.__usuId

    def getNome(self):
        return self.__usuNome



        
        

        



        
    
